<!DOCTYPE html>
<html>
<head>
	<title></title>
	<meta charset="utf-8" />
</head>
<body>

</body>
</html>

<script type="text/javascript">
	class A{
		constructor(){//并非必须
			this.name="class_A";//name属性在类里面是关键字
			this.test="test_A";
			console.log(this) //A {name: "class_A"} (另起一行)B {name: "class_A"} //父类子类分别执行了一次
		}
		static staticCallNameA(){
			return "name_A";
		}
		callNameA(){
			return "name_A";
		}
		static cover(){
			return "cover_A"
		}
	}
	class B extends A{
		constructor(){//子类可以不加
			super();//子类必须有
			console.log(this)//B {name: "class_A"} //会直接打印
		}
		static staticCallNameB(){
			return "nameB";
		}
		callNameB(){
			return "name_B";
		}
		static cover(){
			console.log(this.test,this.super,this);//undefined 父类构造器里的方法直接调用并没有用
			return "cover_B"
		}
	}
	console.log(A.name,B.name) //A B //(类名)
	console.log(A.staticCallNameA(),B.staticCallNameA()) //static子类继承父类
	console.log(A.cover(),B.cover()) //cover_A cover_B //先读子类再读父类
	console.log(A.staticCallNameB) //undefined //父类不具备子类特有函数
	console.log(A.callNameA,B.callNameA) //undefined undefined //非static方法类不能直接调用

	let a=new A(),b=new B; //加不加括号效果一样
	console.log(a.name); //class_A
	console.log(a.name,b.name) //class_A class_A
	console.log(a.callNameA(),a.callNameB,b.callNameB(),b.callNameA()) //name_A undefined name_B name_A //继承关系同上
  console.log(a.staticCallNameA) //static 方法只能通过类名调用
</script> 